home *** CD-ROM | disk | FTP | other *** search
- /** Intercept.vlt
- *
- * Example program to intercept keystrokes.
- * Changes lower case b's into upper case C's, until you type a lower case a.
- *
- **/
-
- /*
- * Open a port
- */
- mp = openport(FOOBAR)
- "message (Now type some lower case b's and other stuff.*NType a lower case a to get out.)"
- /*
- * Tell VLT to send us stuff
- */
- "wedge keystrokes FOOBAR"
- /*
- * Loop until quitflag is 1, waiting for packets
- */
- do forever
- if quitflag = 1 then leave
- t = waitpkt(FOOBAR)
- /*
- * We got a number of packets. Loop over all of them.
- */
- do ff = 1
- p = getpkt(FOOBAR)
- if c2d(p) = 0 then leave ff
- line = getarg(p)
- /*
- * Got a line. It is of the form: KEYSTROKE code qualifier iaddress character
- * parse it out.
- */
- parse var line command code qual iaddr char .
- /*
- * If we got an "a", quit. If a "b", say that we'll handle this one
- * ourselves by replying a 0 error return and replace it with a capital C!
- * Otherwise return a 1.
- */
- if char = 'a' then quitflag = 1
- if char = 'b' then do
- t = reply(p, 0)
- if (char = 'b') then address VLT "send (C); emit (C);"
- end
- else t = reply(p, 1)
- end
- end
-
-